﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using SocialApi.TestApp.Annotations;

namespace SocialApi.TestApp.Models
{
    /// <summary>
    /// Предоствляет список доступных методов API
    /// </summary>
    public class ApiInfo : INotifyPropertyChanged
    {
        /// <summary>
        /// Имя группы
        /// </summary>
        public string GroupName { get; set; }

        /// <summary>
        /// Методы API
        /// </summary>
        public IList<string> ApiMethods { get; set; }

        /// <summary>
        /// Текущий метод API
        /// </summary>
        public string CurrentApiMetod
        {
            get { return _currentApiMetod; }
            set
            {
                _currentApiMetod = value;
                OnPropertyChanged();
                if (CurentApiChanged != null)
                {
                    CurentApiChanged(this, new EventArgs());
                }
            }
        }
        private string _currentApiMetod;

        /// <summary>
        /// Возникает когда изменяет текщий API
        /// </summary>
        public static event EventHandler CurentApiChanged;

        #region Члены INotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}